Re: [GENERAL] Sufficient Primary Key? - Mailing list pgsql-general

From lynch@lscorp.com (Richard Lynch)
Subject Re: [GENERAL] Sufficient Primary Key?
Date
Msg-id v02140b1ab1de4337210b@[207.152.64.133]
Whole thread Raw
List pgsql-general
At 11:06 AM 7/24/98, Dan Delaney wrote:
>Hello all.
>   I'm working on a library catalog and trying to decide what to use
>for the primary key for the authors. Do you think that the first
>three letters of first and last name with the birth year would be
>sufficient (e.g., Alan Watts would be ALAWAT1915). So, essentially,
>do you think there there would ever be two authors with the same
>first and last name AND the same birth year? I really don't want to
>inject the middle name into there because I can't find the middle
>name (or even middle initial) of most authors!

My personal preference is *always* for an integer primary key, which has no
contextual meaningful connection whatsoever with the actual data.

In this particular instance, since you clearly are unsure that you can ever
guarantee uniqueness, there shouldn't even be a question about it:  Use an
auto-incrementing integer.

create sequence authorId;

create table authors(
  Id int4 unique not null default nextval('authorId'),
  .
  .
  .
);

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



pgsql-general by date:

Previous
From: Matt McClure
Date:
Subject: Re: [GENERAL] Nested tables
Next
From: lynch@lscorp.com (Richard Lynch)
Date:
Subject: Re: [GENERAL] Re: [HACKERS] [Fwd: SGVLLUG Oracle and Informix on Linux]